﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace jnxc.Web.factoryinfo
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int fid=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(fid);
				}
			}
		}
			
	private void ShowInfo(int fid)
	{
		jnxc.BLL.factoryinfo bll=new jnxc.BLL.factoryinfo();
		jnxc.Model.factoryinfo model=bll.GetModel(fid);
		this.lblfid.Text=model.fid.ToString();
		this.txtfuser.Text=model.fuser;
		this.txtfpwd.Text=model.fpwd;
		this.txtfname.Text=model.fname;
		this.txtyz.Text=model.yz;
		this.txtzj.Text=model.zj;
		this.txtsd.Text=model.sd;
		this.txtfadd.Text=model.fadd;
		this.txtftel.Text=model.ftel;
		this.txtflinker.Text=model.flinker;
		this.txtfemail.Text=model.femail;
		this.txtfstate.Text=model.fstate.ToString();

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtfuser.Text.Trim().Length==0)
			{
				strErr+="用户名不能为空！\\n";	
			}
			if(this.txtfpwd.Text.Trim().Length==0)
			{
				strErr+="密码不能为空！\\n";	
			}
			if(this.txtfname.Text.Trim().Length==0)
			{
				strErr+="公司名不能为空！\\n";	
			}
			if(this.txtyz.Text.Trim().Length==0)
			{
				strErr+="营业执照不能为空！\\n";	
			}
			if(this.txtzj.Text.Trim().Length==0)
			{
				strErr+="组织机构代码证不能为空！\\n";	
			}
			if(this.txtsd.Text.Trim().Length==0)
			{
				strErr+="税务登记证不能为空！\\n";	
			}
			if(this.txtfadd.Text.Trim().Length==0)
			{
				strErr+="地址不能为空！\\n";	
			}
			if(this.txtftel.Text.Trim().Length==0)
			{
				strErr+="电话不能为空！\\n";	
			}
			if(this.txtflinker.Text.Trim().Length==0)
			{
				strErr+="联系人不能为空！\\n";	
			}
			if(this.txtfemail.Text.Trim().Length==0)
			{
				strErr+="邮箱不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txtfstate.Text))
			{
				strErr+="状态格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int fid=int.Parse(this.lblfid.Text);
			string fuser=this.txtfuser.Text;
			string fpwd=this.txtfpwd.Text;
			string fname=this.txtfname.Text;
			string yz=this.txtyz.Text;
			string zj=this.txtzj.Text;
			string sd=this.txtsd.Text;
			string fadd=this.txtfadd.Text;
			string ftel=this.txtftel.Text;
			string flinker=this.txtflinker.Text;
			string femail=this.txtfemail.Text;
			int fstate=int.Parse(this.txtfstate.Text);


			jnxc.Model.factoryinfo model=new jnxc.Model.factoryinfo();
			model.fid=fid;
			model.fuser=fuser;
			model.fpwd=fpwd;
			model.fname=fname;
			model.yz=yz;
			model.zj=zj;
			model.sd=sd;
			model.fadd=fadd;
			model.ftel=ftel;
			model.flinker=flinker;
			model.femail=femail;
			model.fstate=fstate;

			jnxc.BLL.factoryinfo bll=new jnxc.BLL.factoryinfo();
			bll.Update(model);
			jnxc.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
